@extends('layouts.app')

@section('title', $user->name . ' 的个人中心')

@section('content')

    <div class="row">

        <div class="col-lg-3 col-md-3 hidden-sm hidden-xs user-info">
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="media">
                        <div align="center">
                            <img class="thumbnail img-responsive" src="{{$user->avatar}}">
                        </div>
                        <div class="media-body">
                            <hr>
                            <h4><strong>个人简介</strong></h4>
                            <p>{{$user->introduction}}</p>
                            @if(Auth::user()->id !== $user->id)
                                @if(Auth::user()->isFollowing($user->id))
                                    <form action="{{ route('unfollow', $user->id) }}" method="post">
                                        {{ csrf_field() }}
                                        {{ method_field('DELETE') }}
                                        <button type="submit" class="btn btn-sm">取消关注</button>
                                    </form>
                                @else
                                    <form action="{{route('follow',$user->id)}}" method="post">
                                        {{csrf_field()}}
                                        <button type="submit" class="btn btn-sm">关注</button>
                                    </form>
                                @endif
                            @endif
                            <hr>
                            @foreach($followers as $follower)
                            {{$follower->name}}</br>
                            @endforeach
                            {{$followers->links()}}
                        </div>
                    </div>

                </div>
            </div>
        </div>
        <div class="col-lg-9 col-md-9 col-sm-12 col-xs-12">
            <div class="panel panel-default">
                <div class="panel-body">
                <span>
                    <h1 class="panel-title pull-left" style="font-size:30px;">{{ $user->name }} <small>{{ $user->email }}</small></h1>
                </span>
                </div>
            </div>
            <hr>

            {{-- 用户发布的内容 --}}
            <div class="panel panel-default">
                <div class="panel-body">
                    <ul class="nav nav-tabs">
                        <li class="{{active_class(if_query('tab',null))}}">
                            <a href="{{route('users.show',$user->id)}}">Ta 的话题</a>
                        </li>
                        <li class="{{active_class(if_query('tab','replies'))}}">
                            <a href="{{route('users.show',[$user->id,'tab' => 'replies'])}}">Ta的回复</a>
                        </li>
                    </ul>
                    @if(if_query('tab','replies'))
                        @include('users._replies',['replies'=>$user->replies()->with('topic')->recent()->paginate(5)])
                    @else
                        @include('users._topics',['topics'=>$user->topics()->recent()->paginate(5)])
                    @endif
                </div>
            </div>

        </div>
    </div>
@stop